from typing import List
from list_node import ListNode

class Solution:
   def ReverseList(self , head: ListNode) -> ListNode:
        if not head or not head.next:
            return head
        last = None
        while head:
           tmp = head.next
           head.next = last
           last = head
           head = tmp
        return last

